var app = getApp();
Page({
    data:{
        inited : false,
        helplist : [],
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;
        var rid = options.id ? options.id : ( options.scene ? options.scene : 0 );
        var zfid = options.zfid ? options.zfid : '';
        
        self.setData({
            options : options
        })
        app.com.auth(function(user){
            app.com.http('redbag','POST',{rid:rid,op:'info',zfid:zfid},0,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        Pagetheme : res.data.data.params.style,
                        params : res.data.data.params,
                        redbag : res.data.data.redbag,
                        isgeted : res.data.data.isgeted,
                        goodlist : res.data.data.goodlist,
                        helplist : res.data.data.helplist,
                        inited : true,
                        sharedata : res.data.data.sharedata,
                    });
                    // 关闭下拉刷新
                    wx.stopPullDownRefresh();

                    wx.setNavigationBarTitle({
                      title:  res.data.data.redbag.name,
                    });

                }else{
                    app.com.alert(res.data.message);
                }
            });
        })
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.setData({
            isdown : true,
        });
        
        this.onLoad( this.data.options );
        this.setData({
            isdown : false,
        });
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.sharedata.title,
            path: self.data.sharedata.path,
            imageUrl : self.data.sharedata.img,
        }
    },
    scrollTogoods: function(t) {
        wx.createSelectorQuery().select(".sub_title").boundingClientRect(function(t) {
            var a = t.top;
            wx.pageScrollTo({
                scrollTop: a,
                duration: 0
            });
        }).exec();
    },
    showRules : function(){
        this.setData({
            showRules : true,
        });
    },
    hideRules : function(){
        this.setData({
            showRules : false,
        });
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    switchTab(e){
        wx.switchTab({
            url: e.currentTarget.dataset.url
        });
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },
    FormIdsubmit : function(e){
        if( app.globalData.formarr.length <= 20 ) app.globalData.formarr.push(e.detail.formId);
    },

})